<template>
  <div>
    <p>用户:<select v-model="user">
      <option :value="i.id" v-for="i in list">{{i.username}}</option>
    </select></p>
    <p>性别:<input type="radio" v-model="gender" name="gender" value="男">男
          <input type="radio" v-model="gender" name="gender" value="女">女</p>
    <p>年龄:<input type="text" v-model="age"></p>
    <p>邮箱:<input type="text" v-model="email"></p>
    <p>家庭住址:<input type="text" v-model="address"></p>
    <p>详细地址:<textarea v-model="detailedaddress">

    </textarea></p>
    <p><button @click="btn">添加</button></p>
  </div>

</template>

<script>
    export default {
        data(){
          return{
            detailedaddress:'',
            age:'',
            gender:'',
            address:'',
            email:'',
            token:sessionStorage.getItem('token'),
            list:[],
            user:'1'
          }
        },
        methods:{
          btn(){
            let formdata=new FormData()
            formdata.append('detailedaddress',this.detailedaddress)
            formdata.append('age',this.age)
            formdata.append('gender',this.gender)
            formdata.append('address',this.address)
            formdata.append('user',this.user)
            formdata.append('email',this.email)
            this.axios({
              url:'http://127.0.0.1:8000/app01/add_users/',
              method:'post',
              data:formdata
            }).then(res=>{
              console.log(res)
            })
          }
        },
        created() {
          this.axios({
              url:'http://127.0.0.1:8000/app01/register/',
              method:'get',
            }).then(res=>{
              console.log(res)
            this.list=res.data
            })
        }
    }
</script>

<style scoped>

</style>